package imp

import (
	"bgs/cache/redisImp"
	"bgs/conf"
	"bgs/db"
	"bgs/grpc/client"
	orderGrpc "bgs/grpc/gen/service/order"
	activityService "bgs/service/activity"
	brandService "bgs/service/brand"
	enforcementService "bgs/service/enforcement"
	orderService "bgs/service/order"
	paymentService "bgs/service/payment"
	storeService "bgs/service/store"
	userService "bgs/service/user"
	"bgs/util"
	"context"

	"go.uber.org/zap"
)

// OrderAPIService :grpc server proxy of order
type OrderAPIService struct {
	dao  *db.PgDao
	slog *zap.SugaredLogger
	orderGrpc.OrderOpServer
	cacher             *cache.Adapter
	activityService    *activityService.ActivityServiceImp
	brandService       *brandService.BrandServiceImp
	enforcementService *enforcementService.EnforcementServiceImp
	orderService       *orderService.OrderServiceImp
	paymentService     *paymentService.PaymentServiceImp
	storeService       *storeService.StoreServiceImp
	userService        *userService.UserServiceImp
}

// NewOrderAPIService initialization
func NewOrderAPIService(
	pgdao *db.PgDao,
	slog *zap.SugaredLogger,
	vars *conf.VarsSection,
	proxy *client.GrpcClientProxy,
	adp *cache.Adapter,
	activityService *activityService.ActivityServiceImp,
	brandService *brandService.BrandServiceImp,
	enforcementService *enforcementService.EnforcementServiceImp,
	orderService *orderService.OrderServiceImp,
	paymentService *paymentService.PaymentServiceImp,
	storeService *storeService.StoreServiceImp,
	userService *userService.UserServiceImp,
) *OrderAPIService {
	return &OrderAPIService{
		dao:                pgdao,
		slog:               slog.With("module", "OrderAPIService"),
		cacher:             adp,
		activityService:    activityService,
		brandService:       brandService,
		enforcementService: enforcementService,
		orderService:       orderService,
		paymentService:     paymentService,
		storeService:       storeService,
		userService:        userService,
	}
}

// NewContextLogger create a SugaredLogger with contextvalue
func (s *OrderAPIService) NewContextLogger(ctx context.Context) *zap.SugaredLogger {
	return util.NewContextLogger(ctx, s.slog)
}
